package com.todo.content.application.frontend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.content.application.frontend.service.ContentInfoAggService;
import com.todo.content.iface.frontend.ContentFrontendIface;
import com.todo.content.iface.frontend.request.*;
import com.todo.content.iface.frontend.response.ContentBaseVO;
import com.todo.content.iface.frontend.response.ContentDetailVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/5/17 14:02
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/content")
@Tag(name = "内容详情前台接口", description = "内容详情前台接口")
public class ContentFrontendController implements ContentFrontendIface {

    @Resource
    private ContentInfoAggService contentInfoAggService;


    @Override
    @Operation(summary = "根据用户查询内容列表")
    @PostMapping("/queryContentBaseByUser")
    public BizPageResponse<ContentBaseVO> queryContentBaseByUser(@RequestBody ContentBaseByUserParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return contentInfoAggService.queryContentBaseByUser(param);
    }

    @Override
    @Operation(summary = "根据内容id查询内容详情")
    @PostMapping("/queryContentDetailById")
    public BizResponse<ContentDetailVO> queryContentDetailById(@RequestBody ContentDetailByIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return contentInfoAggService.queryContentDetailById(param);
    }

    @Override
    @Operation(summary = "新增内容信息")
    @PostMapping("/insertContent")
    public BizResponse<Boolean> insertContent(@RequestBody InsertContentParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return contentInfoAggService.insertContent(param);
    }

    @Override
    @Operation(summary = "更新内容信息")
    @PostMapping("/updateContent")
    public BizResponse<Boolean> updateContent(@RequestBody UpdateContentParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return contentInfoAggService.updateContent(param);
    }

    @Override
    @Operation(summary = "根据内容主键删除内容信息")
    @PostMapping("/removeContentById")
    public BizResponse<Boolean> removeContentById(@RequestBody RemoveContentByIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return contentInfoAggService.removeContentById(param);
    }

    @Override
    @Operation(summary = "根据内容Id举报内容信息")
    @PostMapping("/reportContentById")
    public BizResponse<Boolean> reportContentById(@RequestBody ReportContentByIdParam param) {

        return null;
    }
}
